package co.edu.aplicacion.servicios.impl;

import java.io.FileInputStream;

import javazoom.jl.player.Player;

public class HiloReproductor extends Thread {

	private Player player;
	private String archivo;
	
	public HiloReproductor(String ruta){
		this(ruta, 0);
	}
	
	public HiloReproductor(String ruta,int posicion){
		this.archivo=ruta;
	}

	public void run() {
		try{
			detener();
			player=new Player(new FileInputStream(archivo));
			player.play();
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void detener() {
		if(player!=null){
			player.close();
			player=null;
		}
	}
	
	public int pausar(){
		int pos=player.getPosition();
		player.close();
		return pos;
	}

}
